package top.chmin.project.cloud.sys.index.column.info;

import java.util.stream.Stream;
import java.util.List;
import java.util.ArrayList;

import top.chmin.project.cloud.common.*;
import lombok.experimental.Accessors;
import lombok.Setter;
import lombok.Getter;



/**
 * chmin
 * 2024-01-26 13:56:02
 * cloud-code
 */
public class IndexColumnInfoCondition extends Condition {
    private IndexColumnInfoCondition parent = null;

    IndexColumnInfoCondition() {
    }

    private IndexColumnInfoCondition(IndexColumnInfoCondition condition) {
        this.parent = condition;
    }

    public static IndexColumnInfoCondition forDelete() {
        IndexColumnInfoCondition condition = new IndexColumnInfoCondition();
        condition.setSql("DELETE FROM sys_index_column_info#where##group##order##limit#");
        return condition;
    }

    public static IndexColumnInfoCondition forSelect() {
        IndexColumnInfoCondition condition = new IndexColumnInfoCondition();
        condition.modelClass = IndexColumnInfo.class;
        condition.setSql("SELECT #select# FROM sys_index_column_info#where##group##order##limit#");
        return condition;
    }

    public IndexColumnInfoCondition distinct() {
        this.distinct = true;
        return this;
    }

    public IndexColumnInfoCondition limit(int limit) {
        this.limit = " LIMIT " + limit;
        return this;
    }

    public IndexColumnInfoCondition sub() {
        return new IndexColumnInfoCondition(this);
    }

    public IndexColumnInfoCondition finish() {
        if (!whereList.isEmpty()) {
            parent.whereList.add("(" + String.join(" OR ", whereList) + ")");
        }
        parent.whereValueList.addAll(whereValueList);
        return parent;
    }

    public IndexColumnInfo selectFirst() {
        return selectFirst(IndexColumnInfo.class);
    }

    public List<IndexColumnInfo> selectList() {
        return selectList(IndexColumnInfo.class);
    }

    public Stream<IndexColumnInfo> selectStream() {
        return selectStream(IndexColumnInfo.class);
    }

    public Page<IndexColumnInfo> selectPage() {
        return selectPage(IndexColumnInfo.class);
    }

    /*###########auto#start###########*/
    public static int deleteByColumnCodeAndIndexCode(String columnCode, String indexCode) {
        return forDelete().columnCode().eq(columnCode).indexCode().eq(indexCode).execute();
    }

    public static IndexColumnInfo selectByColumnCodeAndIndexCode(String columnCode, String indexCode) {
        return forSelect().columnCode().eq(columnCode).indexCode().eq(indexCode).selectFirst(IndexColumnInfo.class);
    }

    public static <T> T selectByColumnCodeAndIndexCode(String columnCode, String indexCode, Class<T> clazz) {
        return forSelect().columnCode().eq(columnCode).indexCode().eq(indexCode).selectFirst(clazz);
    }

    /*###########auto##end############*/
    /* append $conditionIndexAppender$ */
    /*###########auto#start###########*/
    public ColumnCode columnCode() {
        return new ColumnCode();
    }

    public class ColumnCode extends StringFlexColumn<IndexColumnInfoCondition> {
        private ColumnCode() {
            super(IndexColumnInfoCondition.this, "column_code");
        }
    }

    public ColumnOrderNo columnOrderNo() {
        return new ColumnOrderNo();
    }

    public class ColumnOrderNo extends IntegerFlexColumn<IndexColumnInfoCondition> {
        private ColumnOrderNo() {
            super(IndexColumnInfoCondition.this, "column_order_no");
        }
    }

    public CreateBy createBy() {
        return new CreateBy();
    }

    public class CreateBy extends StringFlexColumn<IndexColumnInfoCondition> {
        private CreateBy() {
            super(IndexColumnInfoCondition.this, "create_by");
        }
    }

    public CreateTime createTime() {
        return new CreateTime();
    }

    public class CreateTime extends LocalDateTimeFlexColumn<IndexColumnInfoCondition> {
        private CreateTime() {
            super(IndexColumnInfoCondition.this, "create_time");
        }
    }

    public Id id() {
        return new Id();
    }

    public class Id extends IntegerFlexColumn<IndexColumnInfoCondition> {
        private Id() {
            super(IndexColumnInfoCondition.this, "id");
        }
    }

    public IndexCode indexCode() {
        return new IndexCode();
    }

    public class IndexCode extends StringFlexColumn<IndexColumnInfoCondition> {
        private IndexCode() {
            super(IndexColumnInfoCondition.this, "index_code");
        }
    }

    public UpdateBy updateBy() {
        return new UpdateBy();
    }

    public class UpdateBy extends StringFlexColumn<IndexColumnInfoCondition> {
        private UpdateBy() {
            super(IndexColumnInfoCondition.this, "update_by");
        }
    }

    public UpdateTime updateTime() {
        return new UpdateTime();
    }

    public class UpdateTime extends LocalDateTimeFlexColumn<IndexColumnInfoCondition> {
        private UpdateTime() {
            super(IndexColumnInfoCondition.this, "update_time");
        }
    }

    /*###########auto##end############*/
    /* append $conditionFieldAppender$ */
}
